/**
 * @description:
 * @author: asd
 * @time: 2022/10/7 0:23
 */
public class Demo2 implements Runnable {

    @Override
    public void run() {
        while (true){
            if(Thread.currentThread().isInterrupted()){
                System.out.println("我被打断了");
                break;
            }else {
                System.out.println("我还在干活");
            }
        }
    }

    public static void main(String[] args) {
        Demo2 demo2 = new Demo2();
        Thread thread = new Thread(demo2);
        thread.start();
        try {
            Thread.sleep(2000);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
        thread.interrupt();
    }
}
